package com.googlecode.yoohoo.xmppcore.stream.features;

import java.util.ArrayList;
import java.util.List;

import com.googlecode.yoohoo.xmppcore.protocol.IFeature;
import com.googlecode.yoohoo.xmppcore.protocol.translation.ITranslator;
import com.googlecode.yoohoo.xmppcore.protocol.translation.IXmlWriter;
import com.googlecode.yoohoo.xmppcore.protocol.translation.XmlWriter;

public class Features implements ITranslator {
	private List<IFeature> features;
	
	public Features() {
		features = new ArrayList<IFeature>();
	}

	public List<IFeature> getFeatures() {
		return features;
	}

	public void setFeatures(List<IFeature> features) {
		this.features = features;
	}

	@Override
	public String toXml() {
		IXmlWriter writer = new XmlWriter();
		writer.writeStartElement("stream", "features");
		
		if (features != null) {
			for (IFeature feature : features) {
				writer.writeCharacters(feature.toXml(), false);
			}
		}
		
		writer.writeEndElement();
		
		return writer.toXml();
	}
	
}
